package com.webservice.client.client;

import com.webservice.client.client.webservice.DemoService;
import com.webservice.client.client.webservice.DemoService_Service;
import com.webservice.client.client.webservice.User;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;

/**
 * description
 *
 * @author luheng
 * create  2019-01-17
 */
public class client {

    /*public static void main(String[] args) {
        // 创建动态客户端
       JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
       Client client = dcf.createClient("http://localhost:8090/demo/api?wsdl");
       // 需要密码的情况需要加上用户名和密码
       // client.getOutInterceptors().add(new ClientLoginInterceptor(USER_NAME, PASS_WORD));
       Object[] objects = new Object[0];
       try {
           // invoke("方法名",参数1,参数2,参数3....);
           objects = client.invoke("getUser", "1");
           System.out.println("返回数据:" + objects[0]);
       } catch (java.lang.Exception e) {
           e.printStackTrace();
       }
    }*/

    /**
     * C:\DevToolInstall\Java8\jdk\bin>wsimport -encoding utf-8 -s D:\git_code\webservice\client\src\main\java -p com.webservice.client.client.webservice http://localhost:8090/demo/api?wsdl
     * -encoding ：指定编码格式（此处是utf-8的指定格式）
     -keep：是否生成Java源文件
     -d：指定.class文件的输出目录
     -s：指定.java文件的输出目录
     -p：定义生成类的包名，不定义的话有默认包名
     */
    public static void main(String[] args) {
        try {
            DemoService_Service service = new DemoService_Service();
            User user = service.getDemoServiceImplPort().getUser("1");
            System.out.println(user.getEmail());
        }catch (java.lang.Exception e){

        }
    }
}
